<template>
	<view class="page">
		<view class="flex flex-direction flex-wrap align-stretch justify-center benben-position-layout flex news_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between news_fd0_0'>
				<view class='flex flex-wrap align-center news_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<image class='news_fd0_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"56.png"'></image>
				</view>
				<text class='news_fd0_0_c1'>消息</text>
				<view class='flex align-center justify-end news_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>

		<view class="information_tabs">
			<u-tabs :list="tabsList" :is-scroll="false" font-size="32" inactive-color="#333333" active-color="#1593FF" bar-width="60" :current="current" @change="change"></u-tabs>
		</view>
		<!---平台消息flex布局开始-->
		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#1593FF"></u-loading>
			<view>加载中</view>
		</view>
		<template v-else>
			<template v-if="current == 0">
				<view class="flex flex-direction flex-wrap align-stretch justify-center benben-flex-layout news_flex_1">
					<template v-for='(item,key0) in platformList'>
						<view class='flex flex-direction flex-wrap align-stretch news_fd1_0'>
							<view class='news_fd1_0_c0'>{{item.title}}</view>
							<view class='news_fd1_0_c3'>
								<text>订单编号：</text>
								<text>{{item.dingdanhao}}</text>
							</view>
							<view class='news_fd1_0_c3'>
								<text>商品名称：</text>
								<text>{{item.kechengmingcheng}}</text>
							</view>
							<view class='news_fd1_0_c2'>{{item.create_time}}</view>
						</view>
					</template>
					<view class="loadmore" v-if="last_page > 1">
						<u-loadmore font-size="24" :status="status" :icon-type="iconType" :load-text="loadText" />
					</view>
				</view>
				<view class="noData" v-if="platformList.length == 0 && !isShow">
					<image :src='STATIC_URL+"no.png"'></image>
				</view>
			</template>
			<template v-if="current == 1">
				<view class="flex flex-direction flex-wrap align-stretch justify-center benben-flex-layout news_flex_1">
					<template v-for='(item,key0) in list'>
						<view class='flex flex-direction flex-wrap align-stretch news_fd1_0' @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/my/messageDetails/messageDetails?id=${item.aid}`" :key='key0'>
							<text class='news_fd1_0_c0'>{{item.title}}</text>
							<view class='news_fd1_0_c1'>
								<u-parse :html="item.intro"></u-parse>
							</view>
							<view class='news_fd1_0_c2'>{{item.create_time}}</view>
						</view>
					</template>
					<view class="loadmore" v-if="last_page > 1">
						<u-loadmore font-size="24" :status="status" :icon-type="iconType" :load-text="loadText" />
					</view>
				</view>
				<view class="noData" v-if="list.length == 0 && !isShow">
					<image :src='STATIC_URL+"no.png"'></image>
				</view>
			</template>
		</template>
		
		

	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},

		data() {
			return {

				tabsList: [{
					name: '平台消息'
				}, {
					name: '系统消息'
				}],
				current: 0,
				"platformList": [],
				"list": [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				"isShow": true,
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			if (this.current == 0) {
				this.getgetPlatform();
			} else {
				this.getSystem();
			}
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			if (this.current == 0) {
				this.getgetPlatform();
			} else {
				this.getSystem();
			}
		},
		// 上拉加载
		onReachBottom() {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			setTimeout(() => {
		
				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.is_pull = false;
				if (this.current == 0) {
					this.getgetPlatform();
				} else {
					this.getSystem();
				}
			}, 500)
		},
		onPageScroll(e) {

		},
		methods: {
			change(index) {
				this.current = index;
				this.page = 1;
				this.is_pull = true;
				this.isShow = true;
				if (this.current == 0) {
					this.getgetPlatform();
				} else {
					this.getSystem();
				}
			},
			// 平台消息  post5cc56966e9287
			getgetPlatform() {
				this.$api.post(global.apiUrls.post5cc56966e9287, {
					page: this.page
				}).then(res => {
					// console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.platformList = res.data.data.data;
						} else {
							this.platformList = this.platformList.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			
			// 系统消息  post6309960573bcc
			getSystem() {
				this.$api.post(global.apiUrls.post6309960573bcc, {
					page: this.page
				}).then(res => {
					// console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.list = res.data.data.data;
						} else {
							this.list = this.list.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
		}
	};
</script>
<style lang="scss" scoped>
	.information_tabs {
		height: 80rpx;
		width: 100%;
		position: fixed;
		z-index: 10;
	}

	.news_fd2_0 {
		width: 100%;
		padding: 50rpx 0rpx 50rpx 0rpx;
	}

	.news_fd2_0_c0 {
		width: 400rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.news_fd2_0_c1 {
		padding: 30rpx 0rpx 0rpx 0rpx;
		color: #929292;
	}

	.news_fd1_0 {
		background: #fff;
		background-size: 100% !important;
		padding: 24rpx 24rpx 32rpx 24rpx;
		background-size: 100% auto !important;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 0rpx 0rpx 20rpx 0rpx;
	}

	.news_fd1_0_c0 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.news_fd1_0_c1 {
		margin: 32rpx 0rpx 0rpx 0rpx;
		line-height: 43rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
	}
	.news_fd1_0_c3 {
		margin: 24rpx 0rpx 0rpx 0rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
	}

	.news_fd1_0_c2 {
		margin: 24rpx 0rpx 0rpx 0rpx;
		line-height: 33rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		border-top: 1rpx solid #eee;
		padding-top: 24rpx;
	}

	.news_flex_1 {
		padding: 100rpx 32rpx 0rpx 32rpx;
	}

	.news_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.news_fd0_0_c0 {
		width: 40rpx;
		height: 40rpx;
	}

	.news_fd0_0_c0_c0 {
		width: 18rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.news_fd0_0_c1 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
		line-height: 50rpx;
	}

	.news_fd0_0_c2 {
		width: 40rpx;
		height: 40rpx;
	}

	.news_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		background-size: 100% !important;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.page {
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto !important;
	}
</style>